/**
 * zhanjun
 */

$(function() {
	$('#citycode').combotree({
		//初始化分类
	 url:'../region/ser_getRegions.do',
		 onSelect:function(node){			
			   var isleaf = $('#citycode').combotree('tree').tree('isLeaf',node.target);
			   if(!isleaf){
				   alert("请选择具体的子节点！");
				   $('#citycode').combotree('clear');
				   $('#cityval').html("");
				   $("#city").attr("value","");
				   return false;
			   }
			   $("#city").attr("value",node.attributes);
			   $('#cityval').html("["+node.attributes+"]");
		}   
	 
	});
	
	$("#btn_reset").click(function() {
		document.getElementById("dataform").reset();
		$('#cityval').html("");
		location.href='user-admin.html';
		
	});
	/*
	 * 保存事件
	 */

	$("#btn_submit").click(function() {
		var postdata = $('#dataform').serialize();
		
		if($('#dataform').form('validate')){		
			$.ajax({
				type : "POST",
				url : "../user/ser_save.do",
				data : postdata,
				success : function(msg) {
					alert(msg);
					document.getElementById("dataform").reset();
					$('#cityval').html("");
				}
			});
		}
	});

});
